package com.yunduo.world.worker;

import com.google.protobuf.ByteString;
import com.yunduo.world.constant.NetWorkConstant;
import com.yunduo.world.constant.NetWorkOperationConst;
import com.yunduo.world.entity.EntityInfo;
import com.yunduo.world.factory.ChannelWorker;
import com.yunduo.world.utils.ClientUtils;
import com.yunduo.world.utils.EntityBuild;
import com.yunduo.world.utils.NetRoomUtils;

import java.util.List;

/**
 * 通过广播实现状态同步
 */
public class OperationWorker extends ChannelWorker {
    @Override
    public void execute() {
        // 获取发送者id
        EntityInfo.Position pos = getMsg().getPos();
        // 获取接收者列表
        List<String> ids = NetRoomUtils.radioList(pos.getId());
        ids.forEach(id->{
            ClientUtils.get(id).writeAndFlush(getMsg());
        });
    }
}
